package com.androidx.p013lv.base.model;

import android.content.Context;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.androidx.p013lv.base.bean.LikeVideoBean;
import com.androidx.p013lv.base.bean.ReqCollect;
import com.androidx.p013lv.base.bean.VideoListBean;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.JsonParams;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.interfaces.Key;
import com.google.gson.Gson;

/* renamed from: com.androidx.lv.base.model.VideoModel */
public class VideoModel extends ViewModel {
    private String HTTP_TAG = "queryBrushStation";
    private MutableLiveData<BaseRes<LikeVideoBean>> likeVideo;
    private MutableLiveData<BaseRes<VideoListBean>> liveData;
    private MutableLiveData<BaseRes> unLikeVideo;

    public MutableLiveData<BaseRes<VideoListBean>> getLiveData() {
        if (this.liveData == null) {
            this.liveData = new MutableLiveData<>();
        }
        return this.liveData;
    }

    public MutableLiveData<BaseRes<LikeVideoBean>> getLikeVideo() {
        if (this.likeVideo == null) {
            this.likeVideo = new MutableLiveData<>();
        }
        return this.likeVideo;
    }

    public MutableLiveData<BaseRes> getUnLikeVideo() {
        if (this.unLikeVideo == null) {
            this.unLikeVideo = new MutableLiveData<>();
        }
        return this.unLikeVideo;
    }

    public void queryBrushStation() {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().queryBrushStation(), new HttpCallback<BaseRes<VideoListBean>>(this.HTTP_TAG) {
            /* class com.androidx.p013lv.base.model.VideoModel.C10331 */

            public void onLvSuccess(BaseRes<VideoListBean> baseRes) {
                VideoModel.this.liveData.setValue(baseRes);
            }
        });
    }

    public void getBuyVideoList(int i) {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().userBuyVideoData(i, true), new HttpCallback<BaseRes<VideoListBean>>("userBuyVideoData") {
            /* class com.androidx.p013lv.base.model.VideoModel.C10342 */

            public void onLvSuccess(BaseRes<VideoListBean> baseRes) {
                VideoModel.this.liveData.setValue(baseRes);
            }
        });
    }

    public void userCollections(int i) {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().userCollections(i, true), new HttpCallback<BaseRes<VideoListBean>>("userCollections") {
            /* class com.androidx.p013lv.base.model.VideoModel.C10353 */

            public void onLvSuccess(BaseRes<VideoListBean> baseRes) {
                VideoModel.this.liveData.setValue(baseRes);
            }
        });
    }

    public void likeVideo(int i, Context context) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().likeVideo(), JsonParams.build().add(Key.VIDEO_ID, Integer.valueOf(i)).add("brush", true).commit(), new HttpCallback<BaseRes<LikeVideoBean>>("likeVideo", context) {
            /* class com.androidx.p013lv.base.model.VideoModel.C10364 */

            public void onLvSuccess(BaseRes<LikeVideoBean> baseRes) {
                VideoModel.this.likeVideo.setValue(baseRes);
            }
        });
    }

    public void unLikeVideo(int i, Context context) {
        String cancelVideoLike = UrlManager.getInsatance().cancelVideoLike();
        ReqCollect reqCollect = new ReqCollect();
        reqCollect.getVideoIds().add(Integer.valueOf(i));
        HttpUtils.getInsatance().post(cancelVideoLike, new Gson().toJson(reqCollect), new HttpCallback<BaseRes>("cancelVideoLike", context) {
            /* class com.androidx.p013lv.base.model.VideoModel.C10375 */

            public void onLvSuccess(BaseRes baseRes) {
                VideoModel.this.unLikeVideo.setValue(baseRes);
            }
        });
    }

    public void cancelHttp() {
        HttpUtils.getInsatance().cancelTag(this.HTTP_TAG);
        HttpUtils.getInsatance().cancelTag("cancelVideoLike");
        HttpUtils.getInsatance().cancelTag("likeVideo");
        HttpUtils.getInsatance().cancelTag("userBuyVideoData");
        HttpUtils.getInsatance().cancelTag("userCollections");
    }
}
